<%--
  Created by IntelliJ IDEA.
  User: ddd
  Date: 2018/4/19
  Time: 16:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>编辑分组</title>
    <link href="${pageContext.request.contextPath}/static/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/css/bootstrap-datetimepicker.min.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/css/admin.css">
</head>
<body>
<div style="padding: 15px;">
    <form id="fo" class="bs-example bs-example-form" role="form" method='post' enctype="multipart/form-data">
        <div class="input-group" id="update">
            <span class="input-group-addon">修改分组名称</span>
            <%--<input type="text" name="name" placeholder="请输入名称" class="form-control">--%>
        </div>
        <br>
        <button class="btn btn-primary btn-lg btn-block validForm" type="button">提交保存</button>
    </form>
</div>

<script src="${pageContext.request.contextPath}/static/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/static/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/static/layer/layer.js"></script>
<script>
    $(function () {
        var url = location.search;
        var id = url.slice(8);
        $("#update").append($("<input>").addClass("form-control names").attr("type","text").attr("name","name"));
        $(".validForm").click(function () {
            var name = $(".names").val();
            $.ajax({
                type: 'POST',
                url: '/area',
                data: {id:id,
                    name:name,
                    _method:'PUT'},
                success: function (json) {
                    if (json.status == "success") {
                        layer.msg('修改成功', {icon: 1, time: 1000});
                        setTimeout(function () {
                            parent.location.reload();
                        }, 1000);
                    }
                },
                error: function () {
                    layer.msg('服务器繁忙，请刷新页面后重试', {icon: 5, time: 1000});
                }
            });
        });
    })

</script>
</body>
</html>
